home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Demos / AppMaker 2.0b3 / Demo AppMaker 1.5 / Demo AppMaker™ / Demo AppMaker™.rsrc / TmpP_111_Data < prev    next >
Encoding:
Text File  |  1992-04-08  |  3.5 KB  |  163 lines

  1. { %filename% -- application-specific data management }
  2. { Created %date% %time% by AppMaker }
  3.  
  4. { This module contains data structures to access the data in your }
  5. { document's file(s). The purpose is to isolate the details of the }
  6. { data representation into this module and to provide accessor }
  7. { functions for reading/writing logical pieces of the data. }
  8. { For your application, you will probably rewrite most of this. }
  9. { This module will not be regenerated by AppMaker unless you delete it. }
  10.  
  11. Unit %appName%Data;
  12. Interface
  13.  
  14. Uses
  15.     %if lang = MPW%
  16.         Types,
  17.         Quickdraw,
  18.         Controls,
  19.         Events,
  20.         Files,
  21.         Lists,
  22.         Menus,
  23.         StandardFile,
  24.         TextEdit,
  25.  
  26.     %end if%
  27.     Globals,
  28.     Miscellany;
  29.  
  30. { Define the creator type and file type for your application.}
  31. const
  32.     kSignature        = 'XXXX';
  33.     kFileType        = 'TEXT';
  34.  
  35. { Define any appropriate data structures for your application.}
  36. { Add any needed fields to Global's WinInfoRec so that each window}
  37. { can have its own set of data. Your functions will use "cur^"}
  38. { to access the data. Here, in the interface section, you should}
  39. { define only those types which are intended to be visible to}
  40. { modules outside this one. Later, in the implementation section,}
  41. { you can define additional "private" data structures.}
  42. type
  43.     YourStuff        = record
  44.         data:            integer;
  45.     end;
  46.  
  47. {----------}
  48. { Open, Close, Read, Write, Init, and Dispose are called by the}
  49. { AppMaker-generated FileM module to do application-specific file accessing.}
  50.  
  51. Function  OpenAppFile    (vRefNum:        integer;
  52.                          fName:            Str255;
  53.                      var fRefNum:        integer): boolean;
  54. Procedure CloseAppFile    (fRefNum:        integer);
  55. Procedure ReadAppFile     (fRefNum:        integer);
  56. Procedure WriteAppFile    (fRefNum:        integer);
  57. Procedure InitAppData;
  58. Procedure DisposeAppData;
  59.  
  60. { These functions are for accessing your data as logical chunks.}
  61. { They are just models for your own accessor functions;}
  62. { they aren't called by any AppMaker-generated code.}
  63. { Replace them with whatever is suitable for your application.}
  64.  
  65. Procedure AddStuff        (stuff:        YourStuff);
  66. Procedure DeleteStuff;
  67. Function  GetStuff: boolean;
  68. Procedure PutStuff;
  69.  
  70. {----------}
  71. Implementation
  72.  
  73. %if lang = MPW%
  74.     {$D+}
  75.     {$R+}
  76.     {$OV+}
  77.     {$S %unitname%}
  78.  
  79. %end if%
  80. { Define additional "private" data structures.}
  81. type
  82.     MoreStuff        = record
  83.         data:            integer;
  84.     end;
  85.  
  86. {----------}
  87. Procedure AddStuff        (stuff:        YourStuff);
  88. Begin
  89.     with cur^ do begin
  90.     end; {with}
  91. End; {AddStuff}
  92.  
  93. {----------}
  94. Function  GetStuff: boolean;
  95. Begin
  96.     with cur^ do begin
  97.     end; {with}
  98.     GetStuff := false;
  99. End; {GetStuff}
  100.  
  101. {----------}
  102. Procedure PutStuff;
  103. Begin
  104.     with cur^ do begin
  105.     end; {with}
  106. End; {PutStuff}
  107.  
  108. {----------}
  109. Procedure DeleteStuff;
  110. Begin
  111.     with cur^ do begin
  112.     end; {with}
  113. End; {DeleteStuff}
  114.  
  115. {----------}
  116. Procedure InitAppData;
  117. Begin
  118.     with cur^ do begin
  119.     end; {with}
  120. End; {InitAppData}
  121.  
  122. {----------}
  123. Procedure DisposeAppData;
  124. Begin
  125.     with cur^ do begin
  126.     end; {with}
  127. End; {DisposeAppData}
  128.  
  129. {----------}
  130. Function  OpenAppFile    (vRefNum:        integer;
  131.                          fName:            Str255;
  132.                      var fRefNum:        integer): boolean;
  133. Begin
  134.     OpenAppFile := CheckOS (FSOpen (fName, vRefNum, fRefNum));
  135. End; {OpenAppFile}
  136.  
  137. {----------}
  138. Procedure CloseAppFile    (fRefNum:        integer);
  139. var
  140.     okay:            boolean;
  141. Begin
  142.     if fRefNum <> 0 then begin    {could be 0 if closing new document}
  143.         okay := CheckOS (FSClose (fRefNum));
  144.     end;
  145. End; {CloseAppFile}
  146.  
  147. {----------}
  148. Procedure ReadAppFile     (fRefNum:        integer);
  149. Begin
  150.     InitAppData;
  151.     with cur^ do begin
  152.     end; {with}
  153. End; {ReadAppFile}
  154.  
  155. {----------}
  156. Procedure WriteAppFile    (fRefNum:        integer);
  157. Begin
  158.     with cur^ do begin
  159.     end; {with}
  160. End; {WriteAppFile}
  161.  
  162. End. {%appName%Data}
  163.